<script setup>
import { computed, ref } from 'vue';
import { storage } from '@/utils/index.js';
import { onLaunch } from "@dcloudio/uni-app";
import { useWebSocketStore } from '@/store/index.js';
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
  apiKey: "AIzaSyAxzUraLKHoP3ai5WKiFPkDb9LxCwaQKg8",
  authDomain: "banaba2024-a1b0b.firebaseapp.com",
  projectId: "banaba2024-a1b0b",
  storageBucket: "banaba2024-a1b0b.firebasestorage.app",
  messagingSenderId: "532091178619",
  appId: "1:532091178619:web:2a1ac4116ece83cd241cde",
  measurementId: "G-J3FNLEX0C3"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);

// 获取当前语言信息
const userInfo = computed(() => loginStore().userInfo);

// 进入APP初始化websocket
const socketStore = useWebSocketStore();
socketStore.connectSocket();
// 更新媒体查询状态的函数
const updateMediaQuery = () => {
	const mediaQuery = window.matchMedia('(max-width: 1024px)');
	loginStore().setScreen(mediaQuery.matches);
};

onLaunch((option) => {	
	const { path, query } = option;
	
	// 未登录,跳到登录页
	const isLogin = storage.getItem('isLogin');
	updateMediaQuery();
	// 监听窗口大小变化
	window.addEventListener('resize', updateMediaQuery);
	
	if (!isLogin) {
		uni.reLaunch({
			url: '/pages/login/login'
		});
	} else {
		// uni.reLaunch({
		// 	url: '/pages/bible/index'
		// })
	}
});
</script>

<style lang="scss">
html, page {
	--b-white: #ffffff;
	--b-white-soft: #f9f9f9;
	--b-white-mute: #f1f1f1;
	
	--b-black: #000000;
	
	--b-black-soft: #2C3550;
	// --b-black-soft: #101623;
	--b-black-mute: #2f2f2f;
	
	--b-red: #fd1919;
	--b-gray: #c7c7c7;
	--b-blue: #16E;
	
	--b-chat-card: rgba(101, 85, 143, 0.16);
	
	// /* 背景颜色 */
	--bg-layout: var(--b-white-soft); // 项目主体背景色
	--bg-layout-gray: var(--b-gray); // 项目主体背景色

	--h-color: var(--b-red);  // 高亮状态颜色
	--h-color-acitve: #dd0d0d;
	
	--text-color: var(--b-black-soft);       //基本色
	--text-color-base: #858B94; //辅助灰色，如加载更多的提示信息
	--text-color-grey: #e7e8ec; //辅助灰色，如加载更多的提示信息
	--text-color-error: var(--b-red); //颜色高亮，如加载更多的提示信息
	

	--text-color-title: var(--text-color);   // 标题颜色
	--text-color-hight: var(--h-color);
	--text-color-hight-base: var(--h-color-base);
	
	--bg-header: var(--b-white);
}
::-webkit-scrollbar { display: none; }
/*每个页面公共css */
@import "static/scss/reset.scss";
</style>

